#!usr/bin/python
# -*- coding:utf-8 -*-
#Copyright 2024 pysail

import io
import os
import sys
import threading
from datetime import datetime

# 设置控制台输出编码为UTF-8
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')

# file_name = f'amzkindasin_{datetime.now().strftime("%Y%m%d")}'
file_name = 'MGamzkindasin_20241116'
source_folder = r'E:\amazon_project\%s'%file_name

# 获取源文件夹中所有文件，假设有5个文件
files = [f for f in os.listdir(source_folder)]
target_folders =[str(i) for i in range(1, len(files)+1)] if len(files)<=10 else 10

def thread_function(name):
    os.system(r'cd .. && python sail.py spider --kind amazon --plug amazoncontent -workpath %s\%s'% (source_folder,name))

# 创建线程
for i in range(len(target_folders)):
    thread = threading.Thread(target=thread_function, args=(i+1,))
# 启动线程
    thread.start()